package com.functest.orm

import com.functest.framework.BaseFunctionalTest
import org.testng.annotations.DataProvider

/**
 * Created with IntelliJ IDEA.
 * User: KovalevAS
 * Date: 28.06.13
 * Time: 16:58
 * To change this template use File | Settings | File Templates.
 */
class BaseProviderTest extends BaseFunctionalTest {
    static BaseProvider base_provider

//    @Test
//    void getFieldValuesUsingFilters_Test() {
//        //println TestData.base_provider.byId(3)
//        Condition first_condition = Condition.of('id', ConditionOp.GT, 2)
//        Condition second_condition = Condition.of('id', ConditionOp.LT, 4)
////        Condition third_condition = Condition.of('id', ConditionOp.IN, [7, 8])
//
//        List<Condition> condition_list
//
//        asStep('One filter')
//                {
//                    condition_list = [first_condition]
//                    println TestData.base_provider.getFieldValuesUsingFilters('id', condition_list)
//                    assert TestData.base_provider.getFieldValuesUsingFilters('id', condition_list).size() == 2
//                }
//
//        asStep('Several filters')
//                {
//                    condition_list = [first_condition, second_condition]
//                    println TestData.base_provider.getFieldValuesUsingFilters('id', condition_list)
//                    assert TestData.base_provider.getFieldValuesUsingFilters('id', condition_list).size() == 1
//                }
//
//
//    }

    @DataProvider
    Object[][] byIds_SingleTableMappers() {
        [
                [
                        'Single table mapper, multicolumn id field',
                        [TestData.student_table_mapper_with_multicolumn_id_field],
                        ['Sidor_Sidorov', 'Ivan_Ivanov'],
                        2,
                        true
                ],

                [
                        'Single table mapper, multicolumn id field',
                        [TestData.student_table_mapper_with_multicolumn_id_field],
                        ['Bryan_Grifin', 'Stan_Smith'],
                        0,
                        false
                ],

                [
                        'Single table mapper, multicolumn id field',
                        [TestData.student_table_mapper_with_multicolumn_id_field],
                        [],
                        0,
                        true
                ],

                [
                        'Sinlge table mapper, singlecolumn id field',
                        [TestData.student_table_full_mapper],
                        [2, 3],
                        2,
                        true
                ],

                [
                        'Single table mapper, singlecolumn id field',
                        [TestData.student_table_full_mapper],
                        [10, 14, 0],
                        0,
                        false
                ],

                [
                        'Single table mapper, singlecolumn id field, empty list',
                        [TestData.student_table_full_mapper],
                        [],
                        0,
                        true
                ]
        ]
    }

//    @Test(dataProvider = 'byIds_SingleTableMappers')
//    <T> void baseProvider_byIds_singleTableMappers(String desc, List<AbstractTableMapper> mappers, Class<T> clazz, List ids, int expected_size, Boolean positive) {
//        asTest {
//            assert desc
//            BaseProvider<T> bp = new BaseProvider<T>(clazz, mappers)
//            //BaseProvider<TestData.Student> bp = new BaseProvider<TestData.Student>(TestData.Student, mappers)
//            def res_list = bp.byIds(ids)
//            assert res_list.size() == expected_size
////            if (positive) {
////                List key_fields
////                res_list.each { def key ->
////                    key.getProperty(bp.mapper.keyField) >> key_fields
////                }
////                assert key_fields == ids
////            }
//        }
//    }

//    @Test
//    void baseProvider_byIds_MultitableMapper(){
//        asTest {
//            assert desc
//            BaseProvider<TestData.Student> bp = new BaseProvider<TestData.Student>(TestData.Student, maper)
//            assert bp.byIds(ids == expected_size)
//            }
//    }





}
